// 给登录按钮添加点击按钮
document.querySelector('#btn-login').addEventListener('click', async function () {
    const data = serialize(document.querySelector('.login-form'), { hash: true, empty: true })
    try {
        const res = await axios.post('/login', data)
        console.log(res)

        // 存储数据 username和token
        localStorage.setItem('username', res.data.username)
        localStorage.setItem('token', res.data.token)

        setTimeout(() => {
            location.href = './index.html'
        }, 1500);
        showToast(res.message)
    } catch (error) {
        console.dir(error.response.data.message)
        showToast(error.response.data.message)
    }
})